package com.acwing.partition13;

import java.io.*;

/**
 * @author `RKC`
 * @date 2022/2/11 13:02
 */
public class AC1252搭配购买 {

    private static final int N = 10010;
    private static int[] parent = new int[N], v = new int[N], w = new int[N], f = new int[N];

    private static int n = 0, m = 0, vol = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        vol = Integer.parseInt(ss[2]);
        for (int i = 1; i <= n; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]);
            v[i] = a;
            w[i] = b;
        }
        //并查集预处理，转换为01背包
        for (int i = 1; i <= n; i++) parent[i] = i;
        for (int i = 0; i < m; i++) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]), pa = find(a), pb = find(b);
            if (pa != pb) {
                v[pb] += v[pa];
                w[pb] += w[pa];
                parent[pa] = pb;
            }
        }
        for (int i = 1; i <= n; i++) {
            if (find(i) != i) continue;
            for (int j = vol; j >= v[i]; j--) {
                f[j] = Math.max(f[j], f[j - v[i]] + w[i]);
            }
        }
        writer.write(f[vol] + "\n");
        writer.flush();
    }

    private static int find(int x) {
        if (x != parent[x]) parent[x] = find(parent[x]);
        return parent[x];
    }
}
